Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

feature/firmware/src/commonMain/kotlin/org/meshtastic/feature/firmware/FirmwareUsbManager.kt 4d4070c8e1ed73a56ee2f054300a0f62e3fe2e62 (4d4070c8) Text, 2.64 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.firmware

Tff7b72import T7ee787kotlinx.coroutines.flow.Flow

Tff7b72interface T56d364FirmwareUsbManager Tb4b4b4{
Tff7b72fun Td2a8ffdeviceDetachFlowTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Tffa657UnitTff7b72>

T8b949e/**
* Records which serial ports are present, so a port that appears *after* a UF2 write can be told apart from one
* that was already there.
*
* Snapshot-then-diff rather than matching a VID/PID table: bootloader-mode ids are per-board and collide (four
* OTAFIX boards share `239A/0029`), and identifying by serial number needs a permission grant we may not hold yet.
*/
Tff7b72suspend Tff7b72fun Td2a8ffserialPortKeysTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3SetTff7b72<Tffa657StringTff7b72>

T8b949e/**
* Opens the port that appeared since [excluding] was captured and holds DTR asserted, so firmware waiting on a host
* will run.
*
* The nRF52 factory-erase image blocks in `while (!Serial)` before `InternalFS.format()`, and `Serial` only becomes
* truthy once DTR is asserted — without this the erase never starts. A failure here is therefore safe: the image is
* written but has destroyed nothing.
*
* @return true when a port was claimed and DTR held.
*/
Tff7b72suspend Tff7b72fun Td2a8ffunblockCdcPortTb4b4b4(Te6edf3excludingTb4b4b4: Te6edf3SetTff7b72<Tffa657StringTff7b72>Tb4b4b4, Te6edf3waitMillisTb4b4b4: Tffa657LongTb4b4b4, Te6edf3holdMillisTb4b4b4: Tffa657LongTb4b4b4)Tb4b4b4: Tffa657Boolean

T8b949e/**
* Waits up to [waitMillis] for a serial device to be present and ensures the app holds USB permission for it,
* prompting the user when needed.
*
* Post-update verification depends on this: every USB re-enumeration is a new device identity to Android, so the
* grant earned before an update does not carry across the device's reboot — without a fresh one the transport's
* auto-recovery fails with SecurityException and verification times out on a healthy device.
*
* Advisory: reconnection still rides the transport's own recovery; a denial just means verification times out as it
* would have anyway.
*/
Tff7b72suspend Tff7b72fun Td2a8ffensureSerialPermissionTb4b4b4(Te6edf3waitMillisTb4b4b4: Tffa657LongTb4b4b4)Tb4b4b4: Tffa657Boolean
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s